package com.ncs.cns.business.db;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import android.content.Context;

import com.ncs.cns.business.to.Code;
import com.ncs.cns.business.to.CodeType;
import com.ncs.cns.business.to.Event;
import com.ncs.cns.business.to.Resource;
import com.ncs.cns.business.to.TransferObject;
import com.ncs.cns.business.to.UserNcs;
import com.ncs.cns.business.to.UserSessionInfo;
import com.ncs.cns.business.util.JsonConvertor;
import com.ncs.cns.framework.ahibernate.util.CNSDBHelper;

public class DBHelper extends CNSDBHelper {

	private static final String DBNAME = "cns.db";
	private static final int DBVERSION = 3;
	private static final Class<?>[] clazz = { UserSessionInfo.class,
			Event.class, CodeType.class, Code.class, Resource.class, UserNcs.class };

	public DBHelper(Context context) {
		super(context, DBNAME, null, DBVERSION, clazz);
	}

	public List<NameValuePair> buildParamStr(String methodId,String currentUser) {
		TransferObject obj = new TransferObject();
		obj.setMethodId(methodId);
		obj.setCurrentUserId(currentUser);
		String dataStr = JsonConvertor.getInstance().conver2JsonStr(obj);
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("dataStr", dataStr));
		return params;
	}

	public List<NameValuePair> buildParamStr(TransferObject obj) {
		String dataStr = JsonConvertor.getInstance().conver2JsonStr(obj);
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("dataStr", dataStr));
		return params;
	}
}
